package demo;

import java.sql.Connection;

import javax.sql.PooledConnection;

import oracle.jdbc.pool.OracleConnectionPoolDataSource;
import oracle.jdbc.pool.OracleDataSource;

public class CreateConnection {
	public static final String URL = "jdbc:oracle:thin:dv/dv@192.168.6.112:1521:XE";
	private static OracleDataSource ods = null;
	
	public static Connection getConnection(){
		Connection con = null;
		
		try {
			if (ods == null) {
				ods = new OracleDataSource();
				ods.setURL(URL);
			}
			con = ods.getConnection();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		return con;
	}
	
	public static Connection getConnectionPool() throws Exception{
		Connection con = null;
		OracleConnectionPoolDataSource ocds = new OracleConnectionPoolDataSource();
		ocds.setURL(URL);
		ocds.setUser("dv");
		ocds.setPassword("dv");
		PooledConnection pc = ocds.getPooledConnection();
		con = pc.getConnection();
		return con;
	}
}
